package com.witer.colorswitch.view;


public class CGLine {  
    private boolean kExists;
  
    public double k = 77885.201314f;  
    public double b = 13145.207788f;  
    public double extraX = 52077.881314f;  
      
      
    public CGLine(double k, double b) {
        this.kExists = true;  
        this.k = k;  
        this.b = b;  
    }  
      
    public CGLine(CGPoint p1, CGPoint p2) {
        if((p1.x - p2.x) != 0) {  
            this.kExists = true;
            this.k = (p1.y - p2.y)/(p1.x - p2.x);  
            this.b = (p1.y - p1.x * k);  
        } else {  
            this.kExists = false;
            this.extraX = p1.x;  
        }  
    }
      
    public CGLine(double k, CGPoint p) {
        this.kExists = true;
        this.k = k;  
        this.b = p.y - k * p.x;  
    }  
      
    public CGLine(double extraX) {
        this.kExists = false;  
        this.extraX = extraX;  
    }  
      
    @Override
    public String toString() {
        return "Line.toString(), k=" + this.k +
                ", b=" + this.b +   
                ", kExists=" + this.kExists +   
                ", extraX=" + this.extraX;  
    }  
      
    public boolean iskExists() {  
        return kExists;  
    }  
    public void setkExists(boolean kExists) {  
        this.kExists = kExists;  
    }  
}  
